package com.ruicar.afs.cloud.workflow.gwt.processor;

import com.alibaba.fastjson.JSON;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.request.FlowExceptionRequest;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.request.TaskAssignRequest;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.request.TaskCreateRequest;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.request.UpdateBizDataRequest;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.response.FlowExceptionResponse;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.response.TaskAssignResponse;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.response.TaskCreateResponse;
import com.ruicar.afs.cloud.workflow.api.dto.afsprocess.response.UpdateBizDataResponse;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * The type AfsWorkFlowNoticeProcessor
 * <p>Description: </p>
 *
 * @author Fzero
 * @version 1.0
 * @date Created on 2020.07.09 09:22:12
 * @since 1.0
 */
public interface AfsWorkFlowNoticeProcessor {
    /**
     * LOGGER
     * <p>Description: </p>
     */
    static Logger LOGGER = LoggerFactory.getLogger(AfsWorkFlowNoticeProcessor.class);
    /**
     * Afs f low keys list
     * 处理器适用范围，此处配置为 在流程映射端配置的 afs-映射key
     *
     * @return the list
     */
    List<String> afsFLowKeys();

    /**
     * Task created task create response
     * 任务创建后回调节点
     *
     * @param taskCreateRequest task create request
     * @return the task create response
     */
    TaskCreateResponse taskCreated(TaskCreateRequest taskCreateRequest);

    /**
     * Task assigned task assign response
     * 任务分配后回调信息
     *
     * @param taskAssignRequest task assign request
     * @return the task assign response
     */
    TaskAssignResponse taskAssigned(TaskAssignRequest taskAssignRequest);

    /**
     * Update biz data update biz data response
     * 通知业务端更新业务数据
     *
     * @param updateBizDataRequest update biz data request
     * @return the update biz data response
     */
    UpdateBizDataResponse updateBizData(UpdateBizDataRequest updateBizDataRequest);


    /**
     * Assign error flow exception response
     *
     * @param flowExceptionRequest flow exception request
     * @return the flow exception response
     */
    default FlowExceptionResponse assignError(FlowExceptionRequest flowExceptionRequest){
        LOGGER.info("接收到流程异常通知:{}", JSON.toJSONString(flowExceptionRequest));
        FlowExceptionResponse response = new FlowExceptionResponse();
        response.setSuccess(true);
        return response;
    }


    /**
     * Data get error flow exception response
     *
     * @param flowExceptionRequest flow exception request
     * @return the flow exception response
     */
    default FlowExceptionResponse dataGetError(FlowExceptionRequest flowExceptionRequest){
        LOGGER.info("接收到流程异常通知:{}", JSON.toJSONString(flowExceptionRequest));
        FlowExceptionResponse response = new FlowExceptionResponse();
        response.setSuccess(true);
        return response;
    }

    /**
     * Default error flow exception response
     *
     * @param flowExceptionRequest flow exception request
     * @return the flow exception response
     */
    default FlowExceptionResponse defaultError(FlowExceptionRequest flowExceptionRequest){
       LOGGER.info("接收到流程异常通知:{}", JSON.toJSONString(flowExceptionRequest));
       FlowExceptionResponse response = new FlowExceptionResponse();
       response.setSuccess(true);
       return response;
   }
}
